import { Controller } from "../../mvc/core/Controller";
import { MsgTypeImpl } from "../manager/MsgTypeImpl";
import { ISysHistroyModule } from "../../../modules/interfaces/ISysHistroyModule";
import { WindowEvent } from "../../component/window/WindowEvent";
import { Dispatcher } from "../../mvc/core/Dispatcher";
import { DataEvent } from "../events/DataEvent";
import { EventName } from "../mvc/EventName";
import { IView } from "../../mvc/interfaces/IView";
import { SysHistroyModule } from "../../../modules/SysHistroyModule";
//class SysHistoryController
    
    export  class SysHistoryController extends Controller
    {
       

        public addHistroy(arg1: Object, arg2: MsgTypeImpl=null): void
        {
            var loc1=cache.sysHis.addHistroy(arg1.toString(), arg2);
            var loc2=0;
            if (arg2) 
            {
                loc2 = arg2.type;
            }
            if (_view && !_view.isHide) 
            {
                (_view as ISysHistroyModule).addHistory(loc1, loc2);
            }
            return;
        }

        /* internal  */onWindowClose(arg1: WindowEvent): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SysHistoryClose, null));
            return;
        }

        /* internal  */onWindowShow(arg1: WindowEvent): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SysHistoryOpen, null));
            return;
        }

        protected /* override */ initView(): IView
        {
            var loc1=new SysHistroyModule();
            loc1.addEventListener(WindowEvent.CLOSE, this.onWindowClose);
            loc1.addEventListener(WindowEvent.SHOW, this.onWindowShow);
            return loc1;
        }

        protected /* override */ initServer(): void
        {
            super.initServer();
            return;
        }
    }
